import {CSSProperties, defineComponent, h, nextTick, onMounted, onUnmounted, PropType, reactive, ref} from 'vue'

// 自动滚动
export function autoScroll(container: HTMLElement, speed = 1) {
  let timer = null;
  function _scroll() {
    const outerH = container.clientHeight;
    const innerH = container.scrollHeight;
    let scrollH = container.scrollTop;

    if (outerH + scrollH + 5 >= innerH) {
      scrollH = 0;
    } else {
      scrollH += speed;
    }
    container.scrollTo(0, scrollH);

    timer = requestAnimationFrame(_scroll)
  }
  return {
    start: _scroll,
    stop: () => {
      timer && cancelAnimationFrame(timer);
    }
  }
}

interface IState {
  originalWidth: string | number
  originalHeight: string | number
  width?: string | number
  height?: string | number
  observer: null | MutationObserver
}

type IAutoScale =
  | boolean
  | {
  x?: boolean
  y?: boolean
}

